home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11852 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  47 lines

  1. Path: solon.com!not-for-mail
  2. From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: const pointer confusion...
  5. Date: 26 Mar 1996 18:58:44 -0600
  6. Organization: Digital Solutions
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4ja3s4$par@solutions.solon.com>
  10. References: <4j06gm$7oa@solutions.solon.com> <4j41io$nma@solutions.solon.com> <4j6389$3iq@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4j6389$3iq@solutions.solon.com> c2a192@ugrad.cs.ubc.ca
  14. (Kazimir Kylheku) writes:
  15.  
  16. |> In article <4j41io$nma@solutions.solon.com>,
  17. |> Huayong Yang <yang@math.umass.edu> wrote:
  18. |> >
  19. |> >const int *p and int const *p are the same: a pointer to const integer;
  20. |> >int * const p means a const pointer to integer. A little program to
  21. |> >verify it:
  22.  
  23. |> This is true. The grammar of the C language allows type specifiers, type
  24. |> qualifers and storage class specifiers to appear in any order in the syntactic
  25. |> unit ``declaration-specifiers''. Thus,
  26.  
  27. |>     const int i;
  28.  
  29. |> and
  30. |>     int const i;
  31.  
  32. |> are essentially the same declaration. It's probably good style to not use any
  33. |> old arbitrary order, but stick to putting the storage class first (if any),
  34. |> followed by the const or volatile qualifier, followed by the type.
  35.  
  36. I agree about not using any old arbitrary order, but the cv-qualifiers
  37. should definitly come *after* what they modify.  It is only in the
  38. declaration-specifier that you have any freedom.  In the declarator,
  39. the cv-qualifier *must* follow what it modifies.  So why do it any
  40. differently here.
  41.  
  42. --
  43. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  44. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  45. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  46.                 -- A la recherche d'une activitΘ dans une region francophone
  47.